<span style="position:relative">
	<script type="text/javascript">
		$(function(){
			$.fx.speeds._default = 1000;
			$("#pdf_dialog").dialog({
				autoOpen: <?php echo (isset($_SESSION['msg']) ? 'true' : 'false') ?>,
				show: "fade",
				hide: "explode",
				width: 510,
				modal: true
			});
			$(".pdf_button").click(function() {
				$("#pdf_dialog").dialog("open");
				return false;
			});
		});
	</script>
	<a class="button pdf_button" href="javascript:void(0)">PDF Rechnung + Lieferschein</a>
	<div id="pdf_dialog" title="PDF Rechnung + Lieferschein" style="display:none">
       	<?php
       		if(isset($_SESSION['msg'])) {
       			echo '<script type="text/javascript">
						$(function() {
							$(".success_msg").fadeIn(function(){setTimeout(function(){$(".success_msg").hide("slow");}, 5000);});
						});
					</script>';
       			if(isset($_SESSION['msg']['dl'])) {
       				$msg = $_SESSION['msg']['dl'];
       			}
       			if(isset($_SESSION['msg']['gp'])) {
       				$msg .= $_SESSION['msg']['gp'];
       			}
       			if(isset($_SESSION['msg']['sm'])) {
       				$msg .= $_SESSION['msg']['sm'];
       			}
       			unset($_SESSION['msg']);
       			echo $msg;
       		}
       		echo draw_form('print', FILENAME_ORDERS, get_all_get_params(array('action','pdf','dl','gb')) . 'pdf=print_order&action=edit','POST','id="pdf_form"'); ?>
           <table border="0" cellspacing="0" cellpadding="2" width="100%">
           	<?php if(get_pdf($_GET['oID'], false, true)) { ?>
				<tr class="bb">
					<td valign="middle">
						<nobr>PDF liegt auf dem Server:</nobr><br />
						<nobr><i style="font-size:90%"><?php echo image('images/icons/document-pdf-text.png', 'PDF', '', '', 'style="position:relative; top:3px"').' '.get_pdf($_GET['oID'], false, false, true); ?></i></nobr>
					</td>
					<td valign="middle">
						<a class="button" href="<?php echo  href_link('create_pdf_download.php', 'oID='.$_GET['oID']); ?>">PDF Rechnung anzeigen</a>
					</td>
				</tr>
				<tr class="bb">
					<td width="1">
						<nobr><label for="check_generate_rechnung">Die Rechnung noch einmal generieren?</label></nobr><br />
						<nobr><label for="check_lieferschein_generieren">Lieferschein erstellen</label></nobr><br />
						<nobr><label for="check_rechnung_loeschen">Rechnung l&ouml;schen</label></nobr>
					</td>
					<td>
						<input type="radio" class="toogle_choose" name="what_to_do" id="check_generate_rechnung" value="bill" checked="" />
						<?php
							echo ' RechnungsNr: <input type="text" name="pdf_bill_nr" value="'.get_pdf_nr($_GET['oID'], true).'" size="10" /><br />';
						?>
						<input type="radio" class="toogle_choose" name="what_to_do" id="check_lieferschein_generieren" value="delivery" /><br />
						<input type="radio" class="toogle_choose" name="what_to_do" id="check_rechnung_loeschen" value="pdf_rechnung_loeschen" />
					</td>
				</tr>
			<?php } else { ?>
				<tr class="bb">
					<td width="1">
						<nobr><label for="check_generate_rechnung">Rechnung</label> <?php
							if(get_pdf_nr($_GET['oID'],true) > 0)
								echo ' - RechnungsNr: <input type="text" name="pdf_bill_nr" value="'.get_pdf_nr($_GET['oID'], false,true).'" size="10" />';
							else
								echo '- n&auml;chste RechNr: <input type="text" name="pdf_bill_nr" value="'.get_pdf_nr($_GET['oID'], false, true).'" size="10" />';
						?></nobr><br />
						<nobr><label for="check_pdf_lieferschein_generieren">Lieferschein</label></nobr><br />
						<nobr><label for="check_rechnung_loeschen">Rechnung l&ouml;schen</label></nobr>
					</td>
					<td>
						<input type="radio" class="toogle_choose" name="what_to_do" id="check_generate_rechnung" value="bill" checked="" /><br />
						<input type="radio" class="toogle_choose" name="what_to_do" id="check_lieferschein_generieren" value="delivery" /><br />
						<input type="radio" class="toogle_choose" name="what_to_do" id="check_rechnung_loeschen" value="pdf_rechnung_loeschen" />
					</td>
				</tr>
			<?php } ?>
			<tr class="bb">
				<td valign="top">In welcher Sprache?</td>
				<td>
					<?php
						$languages_count = get_languages();
						for ($i = 0; $i < sizeof($languages_count); $i++) {
							echo '<input type="radio" name="pdf_language_id" value="'.$languages_count[$i]['id'].'"'.($i==0 ? ' checked=""' : '').' /> '.$languages_count[$i]['name'].'<br />';
						}
					?>
				</td>
			</tr>
			<?php if(get_pdf($_GET['oID'], false, false, false, false, true) !== false) { ?>
				<tr class="bill">
					<td><nobr><label for="check_pdf_rechnung_senden">Die PDF Rechnung wurde am <?php echo get_pdf($_GET['oID'], false, false, false, false, true); ?> verschickt<br />Nochmal versenden?</label></nobr></td>
					<td><input type="checkbox" name="pdf_rechnung_senden" id="check_pdf_rechnung_senden" value="1" /></td>
				</tr>
			<?php } else { ?>
				<tr class="bill">
					<td><nobr><label for="check_pdf_rechnung_senden">Die PDF Rechnung per Email verschicken?</label></nobr></td>
					<td>
						<input type="checkbox" name="pdf_rechnung_senden" id="check_pdf_rechnung_senden" value="1" />
					</td>
				</tr>
			<?php } ?>
			<tr>
				<td colspan="2" align="right">
					<input type="submit" value="gew&auml;hlte Aktion durchf&uuml;hren" class="button" />
					<?php echo draw_hidden_field('oID', $_GET['oID']) . draw_hidden_field('page', $_GET['page']) . draw_hidden_field('type', 'rechnung'); ?>
				</td>
			</tr>
        </table>
        </form>
	</div>
</span>